package com.tr.rentcar.controller.houtai.admin;

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.tr.rentcar.model.bean.Admin_he;
import com.tr.rentcar.model.bean.Adminrole;
import com.tr.rentcar.model.dao.AdminDao;
import com.tr.rentcar.model.dao.AdminroleDao;

@WebServlet("/houtaiadmin")
public class AdminControllor extends HttpServlet {
	private static final long serialVersionUID = 1L;
	Admin_he admin_he = new Admin_he();
	AdminDao AdminDao = new AdminDao();

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		try {
			List<Admin_he> admin_he = AdminDao.findall();
			req.setAttribute("admin_he", admin_he);
			List<Adminrole> adminrole = new AdminroleDao().findall();
			req.setAttribute("adminrole", adminrole);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		req.getRequestDispatcher("/WEB-INF/jsp/houtai_admin.jsp").forward(req, resp);

	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doGet(req, resp);
	}

}
